require_relative 'lib'
require_relative 'slot'
require_relative 'macrofunc'
require_relative 'scheduler'

puts "Start"

=begin
TODO

optimize get number - half of the Help command is getting numbers

recursive dec or inc as zomby

copy functions

=end

=begin

# f (f (x))
$my_slots[0].left_apply(S)
$my_slots[0].right_apply(K)
$my_slots[0].right_apply(S)
$my_slots[0].left_apply(K)
$my_slots[0].right_apply(S)
$my_slots[0].left_apply(I)
print_slots $my_slots

# added function
$my_slots[0].left_apply(Dbl)
print_slots $my_slots

# adding x argument
$my_slots[0].right_apply(K)
$my_slots[0].right_apply(S)
$my_slots[0].left_apply(Succ)
print_slots $my_slots
$my_slots[0].left_apply(Zero)
print_slots $my_slots

=end


=begin
help($my_slots[2], 10, 11, 9999)
invoke_all
print_slots $my_slots

help($my_slots[2], 11, 10, 20990)
invoke_all
print_slots $my_slots

help($my_slots[2], 10, 11, 23000)
invoke_all
print_slots $my_slots

help($my_slots[2], 11, 10, 25300)
invoke_all
print_slots $my_slots

help($my_slots[2], 10, 11, 27900)
invoke_all
print_slots $my_slots

help($my_slots[2], 11, 10, 30600)
invoke_all
print_slots $my_slots
=end



=begin

help($my_slots[200], 10, 11, t2($my_slots[10].vitality))
invoke_all
print_slots($my_slots, "my")

help($my_slots[200], 11, 12, t2(20990))
invoke_all
print_slots($my_slots, "my")

help($my_slots[200], 12, 13, t2(30000))
invoke_all
print_slots($my_slots, "my")

help($my_slots[200], 13, 14, t2(46300))
invoke_all
print_slots($my_slots, "my")

help($my_slots[200], 14, 15, t2(27900))
invoke_all
print_slots($my_slots, "my")

help($my_slots[200], 15, 16, t2(30600))
invoke_all
print_slots $my_slots
=end

# heeeeeeeeeeeeeeeeeeeeeeaaaaaaal

# 100 - 0.972403772784562

step = 0

for x in 100..200
	$my_slots[x].vitality = 0
end


begin

	Scheduler.new.choose_and_heal
	invoke_all

#	Scheduler.new.choose_and_heal
#	invoke_all

	Scheduler.new.choose_and_kill
	invoke_all

	step += 1
	#puts step
end while $enemy_slots.find{|x| !x.dead?} && step < 1000


puts step
print_slots($my_slots, "my")
puts " "
print_slots($enemy_slots, "enemy")
puts " "
puts "my v #{$my_slots.vitality}"
puts "enemy v #{$enemy_slots.vitality}"
puts $my_slots.vitality.to_f / $enemy_slots.vitality

puts $invokations

